package org.exmaple.springframework;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author DeYou
 * @date 2022/10/26
 */
public class BeanFactory {
    private Map<String,BeanDefinition> beanDefinitionMap = new ConcurrentHashMap<>();

    /**
     * 根据名字获取bean
     * @param name
     * @return 返回 bean 对象
     */
    public Object getBean(String name){
        return beanDefinitionMap.get( name ).getBean();
    }

    /**
     * 注册 beanDefinition
     * @param name
     * @param beanDefinition
     */
    public void registerBeanDefinition(String name,BeanDefinition beanDefinition){
        beanDefinitionMap.put( name, beanDefinition );
    }
}